/*
 * IJA2011, Board game "Clovece nezlob se"
 * grp108
 * Tomáš Mičiak,xmicia00
 * Andrej Martinák, xmarti51
 *
 * 
 */

package src.clovece.game;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.ArrayList;

/**
 *  Class serving as container for game elements and game information
 *  This class is created in singleton pattern
 */
public class GameInfo {
    private static GameInfo instance = new GameInfo();

    public String[] state = new String[4];

    private int port = 12345;
    private Socket socket = null;
    private String host = new String();
    private ArrayList<String> playerNicknames = new ArrayList<String>();
    private BufferedReader rd;
    


    private String playerPassword = "";
    private int yourPosition;
    private int graphicMode = 0;
    private int chosenFigurine = 0;
    
    private boolean gamePhase;
    private boolean hasStarted = false;
    private int die = 5;
    private int playerOnTurn = 0;
    private Figurine selectedFigurine = null;

    private boolean localGame = true;
    private boolean newGame = false;
    private boolean loadedGame = false;
    private boolean joinedGame = false;
    private boolean manualMode = false;
    private int gameBoardSize = 36;
    private int numberOfPlayers = 2;
    private int playersJoined = 0;

    private GameField[] fields = null;
    private ArrayList<GameField> posibleMovesFields = new ArrayList<GameField>();
    private ArrayList<Figurine> posibleMovesFigurines = new ArrayList<Figurine>();
    private Player[] players = null;
    private int[] generatedValues = null;

    private GameInfo() {
        super();
        this.state[0] = "INIT_THROW";
        this.state[1] = "MOVE";
        this.state[2] = "THROW";
        this.state[3] = "END";
    }

    public static GameInfo getGameInfoInstance() {
        return GameInfo.instance;
    }

    public void setGeneratedValues(int[] array) {
        this.generatedValues = array;
    }
    
    public void setHost(String host) {
        this.host = host;
    }

    public int[] getGeneratedValues() {
        return this.generatedValues;
    }

    public void setYourPosition(int p) {
        this.yourPosition = p;
    }

    public int getYourPosition() {
        return this.yourPosition;
    }

    public void setGamePhase(boolean phase) {
        this.gamePhase = phase;
    }

    public boolean getGamePhase() {
        return this.gamePhase;
    }

    public void setHasStarted(boolean value) {
        this.hasStarted = value;
    }

    public boolean getHasStarted() {
        return this.hasStarted;
    }

    public void setGameBoardSize(int size) {
        this.gameBoardSize = size;
    }

    public int getGameBoardSize() {
        return this.gameBoardSize;
    }

    public void setNumberOfPlayers(int count) {
        this.numberOfPlayers = count;
    }

    public int getNumberOfPlayers() {
        return this.numberOfPlayers;
    }

    public void setLocalGame(boolean value) {
        this.localGame = value;
    }

    public boolean getLocalGame() {
        return this.localGame;
    }

    public void setNewGame(boolean value) {
        this.newGame = value;
    }

    public boolean getNewGame() {
        return this.newGame;
    }

    public void setLoadedGame(boolean value) {
        this.loadedGame = value;
    }

    public boolean getLoadedGame() {
        return this.loadedGame;
    }

    public void setJoinedGame(boolean value) {
        this.joinedGame = value;
    }

    public boolean getJoinedGame() {
        return this.joinedGame;
    }

    public void setManualMode(boolean flag) {
        this.manualMode = flag;
    }

    public boolean getManualMode() {
        return this.manualMode;
    }

    public void setPlayerNickname(String nickname, int i) {
        this.playerNicknames.add(i, nickname);
    }

    public String getPlayerNickname(int i) {
        return this.playerNicknames.get(i);
    }

    public void setPlayerPassword(String pass) {
        this.playerPassword = pass.toString();
    }

    public String getHost() {
        return this.host;
    }

    public String getPlayerPassword() {
        return this.playerPassword;
    }

    public void setPlayers(Player[] p) {
        this.players = p;
    }

    public Player[] getPlayers() {
        return this.players;
    }

    public void setFields(GameField[] p) {
        this.fields = p;
    }

    public GameField[] getFields() {
        return this.fields;
    }

    public void setPlayerOnTurn(int onTurn) {
        this.playerOnTurn = onTurn;
    }

    public int getPlayerOnTurn() {
        return this.playerOnTurn;
    }

    public void setSelectedFigurine(Figurine f) {
        this.selectedFigurine = f;
    }

    public Figurine getSelectedFigurine() {
        return this.selectedFigurine;
    }

    public void setGraphicMode(int mode) {
        this.graphicMode = mode;
    }

    public int getGraphicMode() {
        return this.graphicMode;
    }

    public void setChosenFigurine(int figure) {
        this.chosenFigurine = figure;
    }

    public int getChosenFigurine() {
        return this.chosenFigurine;
    }

    public void setDie(int die) {
        this.die = die;
    }

    public int getDie() {
        return this.die;
    }

    public void setPlayersJoined(int i) {
        this.playersJoined = i;
    }

    public int setPlayersJoined() {
        return this.playersJoined;
    }

    public void setPosibleMovesFields(ArrayList<GameField> p) {
        this.posibleMovesFields = p;
    }

    public ArrayList<GameField> getPosibleMovesFields() {
        return this.posibleMovesFields;
    }

    public void setPosibleMovesFigurines(ArrayList<Figurine> p) {
        this.posibleMovesFigurines = p;
    }

    public ArrayList<Figurine> getPosibleMovesFigurines() {
        return this.posibleMovesFigurines;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getPort() {
        return this.port;
    }
    
    public void setSocket(Socket socket) {
        this.socket = socket;
    }

    public Socket getSocket() {
        return this.socket;
    }

    public void setInputStream(BufferedReader reader) {
        this.rd = reader;
    }

    public BufferedReader getInputStream() {
        return this.rd;
    }

}
